<template>
  <div>
    <h1>添加商品</h1>
    <p>商品名称：<input type="text" v-model="from.name"></p>
    <p>商品价格：<input type="text" v-model="from.price"></p>
    <p>商品库存：<input type="text" v-model="from.kc"></p>
    <p>图片：<input type="file" id="pic"></p>
    <button @click="post_shop">添加</button>

  </div>
</template>

<script>


export default {
  name: "shopsM",
  data() {
    return {
      from: {}
    }
  },
  methods: {
    post_shop() {
      let pic = document.getElementById('pic').files[0]
      let srom = new FormData()
      srom.append('name', this.from.name)
      srom.append('price', this.from.price)
      srom.append('kc', this.from.kc)
      srom.append('pic', pic)
      this.$axios.post('users/shopM', srom).then(res => {
        if (res.data.code == 200) {
          alert('ok') 
        } else {
          alert('no')
        }
      })
    }
  }
}
</script>

<style scoped>

</style>
